/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.CES.businessLogic;

import com.bionic.CES.DAO.ISystemaccDAO;
import com.bionic.CES.beans.Systemacc;
import com.bionic.CES.connections.DAOFactory;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author Jarik
 */
public class SystemAccService {

    public static ISystemaccDAO systemaccDAO;

    static {
        DAOFactory factory = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
        systemaccDAO = factory.getSystemaccDAO();
    }

    public static void createNewSystemacc(Double amount, String status, String currency, Integer userId) {
        Systemacc systemacc = new Systemacc();
        systemacc.setAmount(amount);
        systemacc.setStatus(status);
        systemacc.setCurrency(currency);
        systemacc.setUserId(userId);

        try {
            systemaccDAO.add(systemacc);
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

    public static void updateCurrentSystemacc(Double amount, String status, String currency, Integer userId) {
        Systemacc systemacc = new Systemacc();
        systemacc.setAmount(amount);
        systemacc.setStatus(status);
        systemacc.setCurrency(currency);
        systemacc.setUserId(userId);
        try {
            systemaccDAO.update(systemacc);
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

    public static void deleteCurrentSystemacc(Integer AccNum) {
        try {
            systemaccDAO.deleteByAccNum(AccNum);
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

    public static List<Systemacc> returnCurrentSystemaccInfo(Integer userId) {
        List<Systemacc> list = null;
        Systemacc systemacc = new Systemacc();
        systemacc.setUserId(userId);
        try {
            list = systemaccDAO.findByDynamicSelect(systemacc);
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return list;
    }

}
